package com.example.demo.controller;

import com.example.demo.model.MoneyLending;
import com.example.demo.service.MoneyLendingService;
import com.example.demo.tool.ResponseMessage;
import com.example.demo.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* 编写人:冷梓硕
*
* */

@RestController("/MoneyLending")
public class MoneyLendingController {
    @Autowired
    private MoneyLendingService moneyLendingService;

    @CrossOrigin
    @RequestMapping(value = "/getMoney")
    public String getMoney(String money){
        return "你输入的名字叫" +money;
    }
    @CrossOrigin
    @RequestMapping(value = "/getOneMon")
    public MoneyLending getOneMon(Integer mid) {
        return moneyLendingService.MoneyLendingKey(mid);
    }


    @CrossOrigin
    @RequestMapping(value = "/getEnterPrise1")
    public List<MoneyLending> getEnterPrise(){
        System.out.println("调用角色全部类型的接口");
        List<MoneyLending> listMoneyLending=moneyLendingService.getEnterPrise();
        return listMoneyLending;
    }

    @CrossOrigin
    @RequestMapping(value = "/getAllMon")
    public ResponseMessage getAllMon(){
        System.out.println("调用角色全部信息的方法");
        Map<String,List> map=new HashMap<>();
        List<MoneyLending> moneyLendings=moneyLendingService.getAllMon();
        map.put("list",moneyLendings);
        return Result.success("200",map);
    }

    @CrossOrigin
    @RequestMapping(value = "/delMoneyLending",method = RequestMethod.GET)
    public int delMoneyLending(Integer mid){
        return moneyLendingService.delMoneyLending(mid);
    }

    @CrossOrigin
    @RequestMapping(value = "/addMoneyLending",method = RequestMethod.PUT)
    public int addMoneyLending(@RequestBody MoneyLending moneyLendingmodel){
        if (moneyLendingmodel!=null){

        }else {

        }
        return moneyLendingService.insertMoneyLending(moneyLendingmodel);
    }

    @CrossOrigin
    @RequestMapping(value = "editMoneyLending",method = RequestMethod.PUT)
    public int editMoneyLending(@RequestBody MoneyLending moneyLendingmodel){
        if (moneyLendingmodel!=null){}else {}
        return moneyLendingService.editMoneyLending(moneyLendingmodel);
    }


    }
